const router = require('koa-router')()
const service = require('../service/libraryService')

router.get('/library/searchByName', async (ctx, next) => {
  await next();
  console.log(ctx.request.query.q);
  ctx.body = await service.searchLibrary(ctx.request.query.q);
});

router.post('/library/install', async (ctx, next) => {
  await next();
  const {name, repository} = ctx.request.body;
  const result = await service.installLibrary(name, repository);
  ctx.body = result;
});

module.exports = router;